package com.fanghaoran.controller;

import com.fanghaoran.bean.Interaction;
import com.fanghaoran.service.ManagerService;

import java.io.IOException;
import java.sql.SQLException;

/**
 * @Author: win11
 * @Date: 2023/03/27/22:39
 * @Description:
 */
public class ManagerController {
    private final ManagerService managerService = new ManagerService();

    //管理员获取用户信息
    /**
     *管理员获取全部用户信息
     */
    public Interaction getUserInfo() throws Exception {
        return managerService.getUserInfo();
    }

    /**
     *管理员通过用户名获取特定用户信息
     */
    public Interaction getUserInfoByUsername(String username) throws Exception {
        return managerService.getUserInfoByUsername(username);
    }

    /**
     *管理员通过电话号码获取特定用户信息
     */
    public Interaction getUserInfoByTelephone(String telephone) throws Exception {
        return managerService.getUserInfoByTelephone(telephone);
    }

    /**
     *管理员通过昵称获取特定用户信息
     */
    public Interaction getUserInfoByNickname(String nickname) throws Exception {
        return managerService.getUserInfoByNickname(nickname);
    }

    /**
     *管理员拉黑用户
     */
    public void updateBlocked(Long newValue, String username) throws SQLException {
        managerService.updateBlocked(newValue, username);
    }



     //单词的增删查改

    /**
     * 添加单词
     */
    public Interaction insertWord(String word, String translation, String bookName) throws Exception {
        return managerService.insertWord(word, translation, bookName);
    }

    /**
     * 获取特定书籍的单词数据
     */
    public Interaction selectWordOfBook(String bookName) throws Exception {
        return managerService.selectWordOfBook(bookName);
    }

    /**
     * 删除特定书籍的单词数据
     */
    public Interaction deleteWordFromBook(String word,String bookName) throws Exception {
        return managerService.deleteWordFromBook(word,bookName);
    }

    /**
     * 修改单词
     */
    public Interaction modifyWord(String word,String translation,String preWord) throws SQLException {
        return managerService.modifyWord(word,translation,preWord);
    }



     //单词书的添加和查看

    /**
     *获取单词书列表
     */
    public Interaction getBookInfo() throws Exception {
        return managerService.getBookInfo();
    }

    /**
     * 添加书籍
     * @param bookName 书籍的名字
     */
    public Interaction insertBook(String bookName) throws Exception {
        return managerService.insertBook(bookName);
    }


    //公告的修改和展示

    /**
     * 展示公告
     */
    public Interaction readNotice() throws IOException {
        return managerService.readNotice();
    }

    /**
     * 修改公告
     * @param text 公告的内容
     */
    public void writeNotice(String text) throws IOException {
        managerService.writeNotice(text);
    }
}
